(function (angular) {
    'user strict';
    var commonModule = angular.module('fs.common');
    commonModule.filter('trustedUrl', ['$sce', function ($sce) {
        return function (value) {
            if (!value) {
                return value;
            }
            return $sce.trustAsUrl(value);
        };
    }]);
    commonModule.filter('trustedResourceUrl', ['$sce', function ($sce) {
        return function (value) {
            if (!value) {
                return value;
            }
            return $sce.trustAsResourceUrl(value);
        };
    }]);
    commonModule.filter('trustedHtml', ['$sce', function ($sce) {
        return function (value) {
            if (!value) {
                return value;
            }
            return $sce.trustAsHtml(value);
        };
    }]);
    commonModule.filter('numberFormat', ['$filter', '$locale', 'formatService', function ($filter, $locale, formatService) {
        return function (number, pattern) {
            if (isNaN(number)) {
                return number;
            }
            return formatService.formatNumber(number, pattern);
        };
    }]);
    commonModule.filter('moneyFormat', ['$filter', '$locale', 'formatService', function ($filter, $locale, formatService) {
        return function (money, pattern) {
            if (isNaN(money)) {
                return money;
            }
            return formatService.formatMoney(money, pattern);
        };
    }]);
    commonModule.filter('percentFormat', ['$filter', '$locale', 'formatService', function ($filter, $locale, formatService) {
        return function (number, pattern) {
            return formatService.formatPercentage(number, pattern);
        };
    }]);
    commonModule.filter('dateFormat', ['$filter', '$locale', 'formatService', function ($filter, $locale, formatService) {
        return function (date, pattern) {
            if (angular.isString(date)) {
                date = formatService.parseDate(date, 'longTimestamp');
            }
            return $filter('date')(date, pattern);
        };
    }]);
})(angular);